import axios from "axios";
const service = axios.create({
	baseURL: process.env.VUE_APP_BASE_API,
	// timeout: 15000,
});

service.interceptors.request.use(
	(config) => {
		return config;
	},
	(error) => {
		return Promise.reject(error);
	}
);

service.interceptors.response.use(
	(response) => {
		const res = response.data;
		if (res.code == 1) {
			return res;
		} else {
			return Promise.reject(new Error(res.message || "Error"));
		}
	},
	(error) => {
		return Promise.reject(error);
	}
);

export default service;
